<?php
/*
* @version 2010-11-03
* @author mxrgus.pxrt
*/


/*
Sepparate proxy is for handeling better logging & auth.


Example:

    $call_create_command    = "LOG CALL"; 
    $call_create_data       = array(
                            'cust_id' => 'clienttt',
                            'updatedb.updatetxt' => 'jo',
                            'callclass' => 'Incident',
                            'owner' => 'mxrguspxrt',
                            'priority' => '1',
                            'prob_text' => 'APPI',
                            );


    $proxy  = new Proxy();
    $result = $proxy->forward(array('command'=>$call_create_command, 'args'=>$call_create_data));

    print_r($result);

*/



// as we are using PHP4, but need JSON support, using external
$json_class_file    = dirname(__FILE__) . '/ext/Json.php';
include_once($json_class_file);



// Proxy commands from X to Supportworks. 
class Proxy extends Object {
    
    // Supporworks server object
    var $supportworks   = null;

    function __construct() {
    }

    // Forward command to Supportworks class instance
    function forward($command, $args) {

        // create supportworks connection if missing
        if(!$this->supportworks) {
            $this->supportworks = new Supportworks();
            $this->supportworks->connect();
        }

        // proxy command
        $command_result = $this->supportworks->call($command, $args);
        return $command_result;
    }

}



